from Tkinter import *
import sys, re

class App(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master, width=600, height=480)
        self.grid(sticky=N+E+S+W)
        
        top=self.winfo_toplevel()
        top.rowconfigure(0, weight=1)
        top.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        
        self.game = __import__(sys.argv[1])
        
        #self.logFrame = Frame(self)
        #self.logScrollbar = Scrollbar(self.logFrame, orient=VERTICAL)
        #self.log = Listbox(self.logFrame, yscrollcommand = self.logScrollbar.set)
        #self.logScrollbar.config(command=self.log.yview)
        #self.logScrollbar.pack(side=RIGHT, fill=Y)
        #self.log.pack(side=LEFT, fill=BOTH, expand=1)
        #self.logFrame.grid(row=0, column=0, sticky=N+E+S+W)
        self.logFrame = Frame(self)
        self.logScrollbar = Scrollbar(self.logFrame, orient=VERTICAL)
        self.log = Text(self.logFrame, yscrollcommand = self.logScrollbar.set)
        self.logScrollbar.config(command=self.log.yview)
        self.logScrollbar.pack(side=RIGHT, fill=Y)
        self.log.pack(side=LEFT, fill=BOTH, expand=1)
        self.logFrame.grid(row=0, column=0, sticky=N+E+S+W)
        
        self.entry = Entry(self)
        self.entry.grid(row=1, column=0, sticky=E+W)
        self.entry.focus_set()
        self.entry.bind("<Return>", self.__entered)
        
        #addtext("", self.game.processor.init())
        #ret = self.game.processor.process(text)
        #if ret: addtext(text, ret)
    def __entered(self, event):
        entered = self.entry.get()
        self.entry.delete(0, END)
        ret = self.game.processor.process(text)
        if ret: addtext(text, ret)
        self.log.insert(END, entered + "\n\n")

root = Tk()
app = App(root)
root.mainloop()
